home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / Quotes 1.0 / src / menus.cp < prev    next >
Encoding:
Text File  |  1995-12-17  |  14.9 KB  |  576 lines  |  [TEXT/KAHL]

  1. #include "menus.h"
  2. #include "main.h"
  3. #include "interface.h"
  4. #include "window.h"
  5.  
  6. extern short selUndo;
  7. extern WindowPtr pwinUndo;
  8.  
  9. short nCurrentFont; // menu item of currently checked font, used to uncheck
  10. short nDefaultFont; // menu item of font when no application window is open
  11. short nCurrentSize;
  12. short nDefaultSize;
  13. short nCurrentVoice;
  14. short nDefaultVoice;
  15.  
  16. const short cSizes = 10;
  17. short sizes[cSizes] = { 0, 9, 10, 12, 14, 18, 24, 36, 48, 72 };
  18.  
  19. // return the font number that is item number nItem in the Font menu
  20. short FontNumber(int nItem) {
  21.     MenuHandle hmenu = GetMenuHandle(MENU_FONT);
  22.     short nFont = 0;
  23.     if (hmenu) {
  24.         Str255 sFontName;
  25.         GetMenuItemText(hmenu, nItem, sFontName);
  26.         GetFNum(sFontName, &nFont);
  27.     }
  28.     return nFont;
  29. } // FontNumber
  30.  
  31. // return item number of the item in the Font menu for font nFont, 0 if item not present
  32. short FontItem(int nFont) {
  33.     MenuHandle hmenu = GetMenuHandle(MENU_FONT);
  34.     short nItem = 0;
  35.     if (hmenu) {
  36.         short cItem = CountMItems(hmenu);
  37.         for (short i = 1; i < cItem+1; i++)
  38.             if (nFont == FontNumber(i))
  39.                 nItem = i;
  40.     }
  41.     return nItem;
  42. } // FontItem
  43.  
  44. void AdjustFonts(void) {
  45.     MenuHandle hmenu = GetMenuHandle(MENU_FONT);
  46.     if (hmenu) {
  47.         CheckItem(hmenu, nCurrentFont, 0);
  48.         WindowPtr pwin = FrontWindow();
  49.         short windowKind;
  50.         if (pwin) {
  51.             windowKind = GetWindowKind(pwin);
  52.             if (windowKind == userKind) {
  53.                 CGrafPtr pPort = GetWindowPort(pwin);
  54.                 short nFont = FontItem(pPort->txFont);
  55.                 nCurrentFont = nFont;
  56.             } else
  57.                 nCurrentFont = nDefaultFont;
  58.         } else
  59.             nCurrentFont = nDefaultFont;
  60.         if (pwin && windowKind==userKind)
  61.             CheckItem(hmenu, nCurrentFont, 1);
  62.         else
  63.             SetItemMark(hmenu, nCurrentFont, diamondMark);
  64.     }
  65. } // AdjustFonts
  66.  
  67. short SizeNumber(short nItem) {
  68.     short nSize;
  69.     if (nItem>=1 && nItem<cSizes)
  70.         nSize = sizes[nItem];
  71.     else
  72.         nSize = 0;
  73.     return nSize;
  74. } // SizeNumber
  75.  
  76. short SizeItem(short nSize) {
  77.     short nItem = 0;
  78.     for (short i=1; i<cSizes; i++)
  79.         if (sizes[i] == nSize) {
  80.             nItem = i;
  81.             break;
  82.         }
  83.     return nItem;
  84. } // SizeItem
  85.  
  86. void AdjustSize(void) {
  87.     MenuHandle hmenu = GetMenuHandle(MENU_SIZE);
  88.     if (hmenu) {
  89.         CheckItem(hmenu, nCurrentSize, 0);
  90.         WindowPtr pwin = FrontWindow();
  91.         short windowKind;
  92.         if (pwin) {
  93.              windowKind = GetWindowKind(pwin);
  94.             if (windowKind == userKind) {
  95.                 CGrafPtr pPort = GetWindowPort(pwin);
  96.                 short nSize = SizeItem(pPort->txSize);
  97.                 nCurrentSize = nSize;
  98.             } else
  99.                 nCurrentSize = nDefaultSize;
  100.         } else
  101.             nCurrentSize = nDefaultSize;
  102.         if (pwin && windowKind==userKind)
  103.             CheckItem(hmenu, nCurrentSize, 1);
  104.         else
  105.             SetItemMark(hmenu, nCurrentSize, diamondMark);
  106.         short nFont = FontNumber(nCurrentFont);
  107.         for (short i=1; i<cSizes; i++)
  108.             if (RealFont(nFont, sizes[i]))
  109.                 SetItemStyle(hmenu, i, outline);
  110.             else
  111.                 SetItemStyle(hmenu, i, 0);
  112.     }
  113. } // AdjustSize
  114.  
  115. void AdjustQuotes(void) {
  116.     MenuHandle hmenu = GetMenuHandle(MENU_QUOTES);
  117.     if (hmenu) {
  118.         WindowPtr pwin = FrontWindow();
  119.         if (pwin) {
  120.             short windowKind = GetWindowKind(pwin);
  121.             if (windowKind < 0)
  122.                 DisableItem(hmenu, 0);
  123.             else {
  124.                 EnableItem(hmenu, 0);
  125.                 QuotesWindow *pqw = (QuotesWindow *)GetWRefCon(pwin);
  126.                 int iCurrent = pqw->current();
  127.                 int count = pqw->count();
  128.                 if (iCurrent == 0) {
  129.                     DisableItem(hmenu, QUOTES_FIRST);
  130.                     DisableItem(hmenu, QUOTES_PREVIOUS);
  131.                 } else {
  132.                     EnableItem(hmenu, QUOTES_FIRST);
  133.                     EnableItem(hmenu, QUOTES_PREVIOUS);
  134.                 }
  135.                 if (iCurrent == count-1) {
  136.                     DisableItem(hmenu, QUOTES_NEXT);
  137.                     DisableItem(hmenu, QUOTES_LAST);
  138.                 } else {
  139.                     EnableItem(hmenu, QUOTES_NEXT);
  140.                     EnableItem(hmenu, QUOTES_LAST);
  141.                 }
  142.                 EnableItem(hmenu, QUOTES_GOTO);
  143.             }
  144.         } else
  145.             DisableItem(hmenu, 0);
  146.     }
  147. } // AdjustQuotes
  148.  
  149. short cVoices;
  150. short *pVoices;
  151. void SetDefaultVoice(void) {
  152.     nDefaultVoice = 1;
  153.     MenuHandle hmenu = GetMenuHandle(MENU_SPEECH);
  154.     if ( (**hmenu).enableFlags & 1) {
  155.         VoiceDescription VD;
  156.         VD.length = sizeof(VoiceDescription);
  157.         GetVoiceInfo(NULL, soVoiceDescription, &VD);
  158.         VoiceSpec VS;
  159.         for (short i=1; i<=cVoices; i++) {
  160.             GetIndVoice(pVoices[i], &VS);
  161.             if (VD.voice.creator==VS.creator && VD.voice.id==VS.id) {
  162.                 nDefaultVoice = i;
  163.                 break;
  164.             }
  165.         }
  166.     }
  167.     nCurrentVoice = nDefaultVoice;
  168. } // SetDefaultVoice
  169.  
  170. void SortVoices(MenuHandle hmenu) {
  171.     if (hmenu) {
  172.         short i, j;
  173.         Str255 sT, sTLoop, sTCopy;
  174.         short iT;
  175.         for (i=2; i<=cVoices; i++) {
  176.             GetMenuItemText(hmenu, i, sT);
  177.             iT = pVoices[i];
  178.             j = i;
  179.             GetMenuItemText(hmenu, j-1, sTLoop);
  180.             while (j>1 && StringOrder(sTLoop, sT, smSystemScript, smSystemScript, systemDefLang, systemDefLang)==1) { // sTLoop>sT
  181.                 GetMenuItemText(hmenu, j-1, sTCopy);
  182.                 SetMenuItemText(hmenu, j, sTCopy);
  183.                 pVoices[j] = pVoices[j-1];
  184.                 j--;
  185.                 if (j>1)
  186.                     GetMenuItemText(hmenu, j-1, sTLoop);
  187.             }
  188.             SetMenuItemText(hmenu, j, sT);
  189.             pVoices[j] = iT;
  190.         }
  191.     }
  192. } // SortVoices
  193.  
  194. void SetupVoices(void) {
  195.     long response;
  196.     OSErr err = Gestalt(gestaltSpeechAttr, &response);
  197.     short fHasSpeech;
  198.     if (err == noErr)
  199.         fHasSpeech = response & (1<<gestaltSpeechMgrPresent);
  200.     else
  201.         fHasSpeech = 0;
  202.     if (fHasSpeech) {
  203.         MenuHandle hmenu;
  204.         hmenu = GetMenu(MENU_VOICES);
  205.         err = CountVoices(&cVoices);
  206.         pVoices = (short *)NewPtr(cVoices*sizeof(short));
  207.         if (err == noErr) {
  208.             VoiceSpec VS;
  209.             VoiceDescription VD;
  210.             long lenVD;
  211.             for (int i = 1; i <= cVoices; i++) {
  212.                 err = GetIndVoice(i, &VS);
  213.                 if (err == noErr) {
  214.                     err = GetVoiceDescription(&VS, &VD, sizeof(VoiceDescription));
  215.                     if (err == noErr) {
  216.                         AppendMenu(hmenu, VD.name);
  217.                         pVoices[i] = i;
  218.                     }
  219.                 }
  220.             }
  221.         }
  222.         InsertMenu(hmenu, -1);
  223.         SortVoices(hmenu);
  224.         SetDefaultVoice();
  225.         hmenu = GetMenuHandle(MENU_SPEECH);
  226.         if (hmenu)
  227.             SetItemMark(hmenu, SPEECH_VOICES, (char)MENU_VOICES);
  228.     } else
  229.         cVoices = 0;
  230. } // SetupVoices
  231.  
  232. void AdjustWindows(void) {
  233.     int fWindows7; // Help item is in the Help menu
  234.     MenuHandle hmenu = GetMenuHandle(MENU_WINDOW_7);
  235.     if (hmenu == NULL) {
  236.         hmenu = GetMenuHandle(MENU_WINDOW_6);
  237.         fWindows7 = 0;
  238.     } else
  239.         fWindows7 = 1;
  240.     if (hmenu) {
  241.         // clear the menu
  242.         int cItems;
  243.         if (fWindows7) {
  244.             cItems = CountMItems(hmenu);
  245.             for (int i = 0; i < cItems; i++)
  246.                 DeleteMenuItem(hmenu, 1);
  247.         } else {
  248.             cItems = CountMItems(hmenu) - 2;
  249.             for (int i = 0; i < cItems; i++)
  250.                 DeleteMenuItem(hmenu, 3);
  251.         }
  252.         // build the menu
  253.         Str255 sWindow;
  254.         short windowKind;
  255.         WindowPtr pwin = FrontWindow();
  256.         while (pwin) {
  257.             windowKind = GetWindowKind(pwin);
  258.             if (windowKind == userKind) {
  259.                 GetWTitle(pwin, sWindow);
  260.                 AppendMenu(hmenu, sWindow);
  261.             }
  262.             pwin = GetNextWindow(pwin);
  263.         }
  264.         pwin = FrontWindow();
  265.         if (pwin) {
  266.             windowKind = GetWindowKind(pwin);
  267.             if (windowKind < 0)
  268.                 EnableItem(hmenu, 0);
  269.             else if (windowKind == userKind) {
  270.                 EnableItem(hmenu, 0);
  271.                 if (fWindows7)
  272.                     CheckItem(hmenu, 1, 1);
  273.                 else
  274.                     CheckItem(hmenu, 3, 1);
  275.             } else if (windowKind == dialogKind)
  276.                 DisableItem(hmenu, 0);
  277.         } else
  278.             if (fWindows7)
  279.                 DisableItem(hmenu, 0);
  280.             else
  281.                 EnableItem(hmenu, 0);
  282.     }
  283. } // AdjustWindows
  284.  
  285. int SetupMenus(void) {
  286.     long response;
  287.     OSErr err = Gestalt(gestaltHelpMgrAttr, &response);
  288.     int fHasHelpMgr;
  289.     if (err == noErr)
  290.         fHasHelpMgr = response & (1<<gestaltHelpMgrPresent);
  291.     else
  292.         fHasHelpMgr = 0;
  293.     Handle hmenus;
  294.     if (fHasHelpMgr)
  295.         hmenus = GetNewMBar(MENUS_7);
  296.     else
  297.         hmenus = GetNewMBar(MENUS_6);
  298.     if (hmenus) {
  299.         SetMenuBar(hmenus);
  300.         DisposHandle(hmenus);
  301.         MenuHandle hmenu = GetMenuHandle(MENU_APPLE);
  302.         if (hmenu)
  303.             AppendResMenu(hmenu, 'DRVR');
  304.         hmenu = GetMenuHandle(MENU_FONT);
  305.         if (hmenu) {
  306.             AppendResMenu(hmenu, 'FONT');
  307.             Str255 sFontName;
  308.             GetFontName(1, sFontName); // 1 is the system default application font number
  309.             short nFont;
  310.             GetFNum(sFontName, &nFont);
  311.             nCurrentFont = FontItem(nFont);
  312.             nDefaultFont = FontItem(nFont);
  313.         }
  314.         if (fHasHelpMgr) {
  315.             Str255 itemString;
  316.             GetIndString(itemString, MENU_STRINGS, STRING_HELP);
  317.             err = HMGetHelpMenuHandle(&hmenu);
  318.             if (err == noErr)
  319.                 AppendMenu(hmenu, itemString);
  320.         }
  321.         SetupVoices();
  322.         AdjustMenus();
  323.         return noErr;
  324.     } else
  325.         return memFullErr;
  326. } // SetupMenus
  327.  
  328. void AdjustVoices(void) {
  329.     MenuHandle hmenu = GetMenuHandle(MENU_VOICES);
  330.     if (hmenu) {
  331.         CheckItem(hmenu, nCurrentVoice, 0);
  332.         WindowPtr pwin = FrontWindow();
  333.         if (pwin) {
  334.             short windowKind = GetWindowKind(pwin);
  335.             if (windowKind < 0)
  336.                 nCurrentVoice = nDefaultVoice;
  337.             else {
  338.                 QuotesWindow *pqw = (QuotesWindow *)GetWRefCon(pwin);
  339.                 for (short i=1; i<=cVoices; i++)
  340.                     if (pVoices[i] == pqw->voice) {
  341.                         nCurrentVoice = i;
  342.                         break;
  343.                     }
  344.             }
  345.         } else
  346.             nCurrentVoice = nDefaultVoice;
  347.         if (pwin)
  348.             CheckItem(hmenu, nCurrentVoice, 1);
  349.         else
  350.             SetItemMark(hmenu, nCurrentVoice, diamondMark);
  351.     }
  352. } // AdjustVoices
  353.  
  354. void AdjustSpeech(void) {
  355.     MenuHandle hmenuSpeech = GetMenuHandle(MENU_SPEECH);
  356.     WindowPtr pwin = FrontWindow();
  357.     long response;
  358.     OSErr err = Gestalt(gestaltSpeechAttr, &response);
  359.     int fHasSpeech;
  360.     if (err == noErr)
  361.         fHasSpeech = response & (1<<gestaltSpeechMgrPresent);
  362.     else
  363.         fHasSpeech = 0;
  364.     MenuHandle hmenuVoices = GetMenuHandle(MENU_VOICES);
  365.     if (fHasSpeech) {
  366.         EnableItem(hmenuSpeech, 0);
  367.         if (SpeechBusy()) {
  368.             DisableItem(hmenuSpeech, SPEECH_SPEAK_ALL);
  369.             EnableItem(hmenuSpeech, SPEECH_STOP_SPEAKING);
  370.             DisableItem(hmenuVoices, 0);
  371.         } else {
  372.             if (pwin)
  373.                 EnableItem(hmenuSpeech, SPEECH_SPEAK_ALL);
  374.             else
  375.                 DisableItem(hmenuSpeech, SPEECH_SPEAK_ALL);
  376.             DisableItem(hmenuSpeech, SPEECH_STOP_SPEAKING);
  377.             EnableItem(hmenuVoices, 0);
  378.         }
  379.         AdjustVoices();
  380.     } else
  381.         DisableItem(hmenuSpeech, 0);
  382. } // AdjustSpeech
  383.  
  384. void AdjustUndo(void) {
  385.     MenuHandle hmenuEdit = GetMenuHandle(MENU_EDIT);
  386.     if (hmenuEdit) {
  387.         if (selUndo == CANT_UNDO)
  388.             DisableItem(hmenuEdit, EDIT_UNDO);
  389.         else {
  390.             WindowPtr pwin = FrontWindow();
  391.             if (pwin) {
  392.                 short windowKind = GetWindowKind(pwin);
  393.                 if (windowKind < 0)
  394.                     EnableItem(hmenuEdit, EDIT_UNDO);
  395.                 else {
  396.                     if (pwin == pwinUndo)
  397.                         EnableItem(hmenuEdit, EDIT_UNDO);
  398.                     else
  399.                         DisableItem(hmenuEdit, EDIT_UNDO);
  400.                 }
  401.             } else
  402.                 if (pwin == pwinUndo)
  403.                     EnableItem(hmenuEdit, EDIT_UNDO);
  404.                 else
  405.                     DisableItem(hmenuEdit, EDIT_UNDO);
  406.         }
  407.         Str255 sItem;
  408.         GetIndString(sItem, MENU_STRINGS, selUndo);
  409.         if (selUndo == CANT_UNDO || selUndo == UNDO)
  410.             SetMenuItemText(hmenuEdit, 1, sItem);
  411.         else
  412.             SetMenuItemText(hmenuEdit, 1, sItem);
  413.     }
  414. } // AdjustUndo
  415.  
  416. void AdjustHelpMenu(void) {
  417.     long response;
  418.     OSErr err = Gestalt(gestaltHelpMgrAttr, &response);
  419.     int fHasHelpMgr;
  420.     if (err == noErr)
  421.         fHasHelpMgr = response & (1<<gestaltHelpMgrPresent);
  422.     else
  423.         fHasHelpMgr = 0;
  424.     Handle hmenus;
  425.     if (fHasHelpMgr) {
  426.         MenuHandle hmenuHelp;
  427.         OSErr err = HMGetHelpMenuHandle(&hmenuHelp);
  428.         if (err == noErr) {
  429.             short cItems = CountMItems(hmenuHelp);
  430.             WindowPtr pwin = FrontWindow();
  431.             if (pwin) {
  432.                 short windowKind = GetWindowKind(pwin);
  433.                 if (windowKind == dialogKind)
  434.                     DisableItem(hmenuHelp, cItems);
  435.                 else
  436.                     EnableItem(hmenuHelp, cItems);
  437.             } else
  438.                 EnableItem(hmenuHelp, cItems);
  439.         }
  440.     }
  441. } // AdjustHelpMenu
  442.  
  443. void AdjustMenus(void) {
  444.     WindowPtr pwin = FrontWindow();
  445.     short windowKind;
  446.     if (pwin)
  447.         windowKind = GetWindowKind(pwin);
  448.     MenuHandle hmenuApple = GetMenuHandle(MENU_APPLE);
  449.     MenuHandle hmenuFile = GetMenuHandle(MENU_FILE);
  450.     MenuHandle hmenuEdit = GetMenuHandle(MENU_EDIT);
  451.     MenuHandle hmenuQuotes = GetMenuHandle(MENU_QUOTES);
  452.     MenuHandle hmenuSpeech = GetMenuHandle(MENU_SPEECH);
  453.     MenuHandle hmenuFont = GetMenuHandle(MENU_FONT);
  454.     MenuHandle hmenuSize = GetMenuHandle(MENU_SIZE);
  455.     short fFileEnabled = (**hmenuFile).enableFlags & 1;
  456.     short fEditEnabled = (**hmenuEdit).enableFlags & 1;
  457.     short fQuotesEnabled = (**hmenuQuotes).enableFlags & 1;
  458.     if (pwin) {
  459.         EnableItem(hmenuFile, FILE_CLOSE);
  460.         EnableItem(hmenuEdit, 0);
  461.         if (windowKind < 0) {
  462.             EnableItem(hmenuApple, 0);
  463.             EnableItem(hmenuFile, 0);
  464.             DisableItem(hmenuFile, FILE_SAVE);
  465.             DisableItem(hmenuFile, FILE_SAVE_AS);
  466.             EnableItem(hmenuEdit, EDIT_CUT);
  467.             EnableItem(hmenuEdit, EDIT_COPY);
  468.             EnableItem(hmenuEdit, EDIT_PASTE);
  469.             EnableItem(hmenuEdit, EDIT_CLEAR);
  470.             DisableItem(hmenuEdit, EDIT_SELECT_ALL);
  471.             DisableItem(hmenuQuotes, 0);
  472.             DisableItem(hmenuSpeech, 0);
  473.             DisableItem(hmenuFont, 0);
  474.             DisableItem(hmenuSize, 0);
  475.         } else if (windowKind == dialogKind) {
  476.             DisableItem(hmenuApple, 0);
  477.             DisableItem(hmenuFile, 0);
  478.             short selDialog = GetWRefCon(pwin);
  479.             switch (selDialog) {
  480.                 case DLOG_ABOUT:
  481.                     DisableItem(hmenuEdit, EDIT_CUT);
  482.                     EnableItem(hmenuEdit, EDIT_COPY);
  483.                     DisableItem(hmenuEdit, EDIT_PASTE);
  484.                     DisableItem(hmenuEdit, EDIT_CLEAR);
  485.                     DisableItem(hmenuEdit, EDIT_SELECT_ALL);
  486.                     break;
  487.                 case DLOG_GOTO:
  488.                     TEHandle hte = ((DialogPeek)pwin)->textH;
  489.                     if ((**hte).selStart == (**hte).selEnd) {
  490.                         DisableItem(hmenuEdit, EDIT_CUT);
  491.                         DisableItem(hmenuEdit, EDIT_COPY);
  492.                         DisableItem(hmenuEdit, EDIT_CLEAR);
  493.                     } else {
  494.                         EnableItem(hmenuEdit, EDIT_CUT);
  495.                         EnableItem(hmenuEdit, EDIT_COPY);
  496.                         EnableItem(hmenuEdit, EDIT_CLEAR);
  497.                     }
  498.                     EnableItem(hmenuEdit, EDIT_PASTE);
  499.                     short item;
  500.                     Rect r;
  501.                     Handle hText;
  502.                     GetDialogItem(pwin, 3, &item, &hText, &r);
  503.                     Str255 s;
  504.                     GetDialogItemText(hText, s);
  505.                     if ((**hte).selStart == 0 && (**hte).selEnd == s[0])
  506.                         DisableItem(hmenuEdit, EDIT_SELECT_ALL);
  507.                     else
  508.                         EnableItem(hmenuEdit, EDIT_SELECT_ALL);
  509.                     break;
  510.             }
  511.             DisableItem(hmenuQuotes, 0);
  512.             DisableItem(hmenuSpeech, 0);
  513.             DisableItem(hmenuFont, 0);
  514.             DisableItem(hmenuSize, 0);
  515.         } else if (windowKind == userKind) {
  516.             EnableItem(hmenuApple, 0);
  517.             EnableItem(hmenuFile, 0);
  518.             EnableItem(hmenuFile, FILE_SAVE_AS);
  519.             QuotesWindow *pqw = (QuotesWindow *)GetWRefCon(pwin);
  520.             if (pqw->save())
  521.                 EnableItem(hmenuFile, FILE_SAVE);
  522.             else
  523.                 DisableItem(hmenuFile, FILE_SAVE);
  524.             DisableItem(hmenuEdit, EDIT_CUT);
  525.             if (1) // text selected in quote window
  526.                 EnableItem(hmenuEdit, EDIT_COPY);
  527.             else
  528.                 DisableItem(hmenuEdit, EDIT_COPY);
  529.             DisableItem(hmenuEdit, EDIT_PASTE);
  530.             DisableItem(hmenuEdit, EDIT_CLEAR);
  531.             if (0) // not all of the text in the window is selected
  532.                 EnableItem(hmenuEdit, EDIT_SELECT_ALL);
  533.             else
  534.                 DisableItem(hmenuEdit, EDIT_SELECT_ALL);
  535.             EnableItem(hmenuQuotes, 0);
  536.             AdjustQuotes();
  537.             AdjustSpeech();
  538.             EnableItem(hmenuFont, 0);
  539.             EnableItem(hmenuSize, 0);
  540.         }
  541.     } else {
  542.         EnableItem(hmenuApple, 0);
  543.         EnableItem(hmenuFile, 0);
  544.         DisableItem(hmenuFile, FILE_CLOSE);
  545.         DisableItem(hmenuFile, FILE_SAVE);
  546.         DisableItem(hmenuFile, FILE_SAVE_AS);
  547.         if (selUndo == CANT_UNDO)
  548.             DisableItem(hmenuEdit, 0);
  549.         else
  550.             EnableItem(hmenuEdit, 0);
  551.         DisableItem(hmenuEdit, EDIT_CUT);
  552.         DisableItem(hmenuEdit, EDIT_COPY);
  553.         DisableItem(hmenuEdit, EDIT_PASTE);
  554.         DisableItem(hmenuEdit, EDIT_CLEAR);
  555.         DisableItem(hmenuEdit, EDIT_SELECT_ALL);
  556.         DisableItem(hmenuQuotes, 0);
  557.         AdjustSpeech();
  558.         EnableItem(hmenuFont, 0);
  559.         EnableItem(hmenuSize, 0);
  560.     }
  561.     AdjustUndo();
  562.     AdjustFonts();
  563.     AdjustSize();
  564.     AdjustWindows();
  565.     AdjustHelpMenu();
  566.     short fRedraw = 0;
  567.     if (fFileEnabled != ((**hmenuFile).enableFlags & 1))
  568.         fRedraw = 1;
  569.     if (fEditEnabled != ((**hmenuEdit).enableFlags & 1))
  570.         fRedraw = 1;
  571.     if (fQuotesEnabled != ((**hmenuQuotes).enableFlags & 1))
  572.         fRedraw = 1;
  573.     if (fRedraw)
  574.         DrawMenuBar();
  575. } // AdjustMenus
  576.